﻿using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Tip : MonoBehaviour
{
    public void Init(string content)
    {
        var rect = transform.Find("Content").GetComponent<RectTransform>();
        var textrect = transform.Find("Content/Text").GetComponent<RectTransform>();
        var text = transform.Find("Content/Text").GetComponent<Text>();
        text.text = content;
        //rect.sizeDelta = new Vector2(textrect.sizeDelta.x + 50, textrect.sizeDelta.y + 10);
        Destroy(gameObject, 1);
    }

    public static void Show(string content)
    {
        GameObject go = Resources.Load<GameObject>("Prefab/UIPrefab/Tip");
        var tip = Instantiate(go);
        tip.transform.SetParent(GameObject.Find("Shop/PurchaseCanvas").transform);
        tip.transform.GetComponent<RectTransform>().localScale = Vector3.one;
        tip.GetComponent<Tip>().Init(content);
    }
}